package pers.wensheng.patterns.behavioral_pattern.visitor_pattern.foundation;

import pers.wensheng.patterns.behavioral_pattern.visitor_pattern.foundation.entity.Animal;
import pers.wensheng.patterns.behavioral_pattern.visitor_pattern.foundation.entity.Person;

import java.util.ArrayList;
import java.util.List;

/**
 * 对象结构
 */
public class Home {
    private List<Animal> list = new ArrayList<>();

    /**
     * 喂
     * @param person
     */
    public void action(Person person){
        for (Animal animal : list) {
            animal.accept(person);
        }
    }

    public void addAnimal(Animal animal){
        list.add(animal);
    }
}
